<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>

    <!-- 18.2.0 最新的 -->
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>

    <script type="text/babel">
      class App extends React.Component {
        handleClick() {
          this.props.hello();
        }

        render() {
          console.log("App props", this.props);
          // this.props.hello()
          return (
            <div>
              <h1>App</h1>
              <button onClick={this.handleClick.bind(this)}>点我</button>
            </div>
          );
        }
      }

      // 18 之前 ReactDOM.render 渲染 React 元素
      // ReactDOM.render(
      //   <App
      //     id="box"
      //     className="message"
      //     style={{ color: "red" }}
      //     hello={() => {
      //       console.log("hello");
      //     }}
      //   />,
      //   document.querySelector("#root")
      // );

      // 18 之后
      ReactDOM.createRoot(document.querySelector("#root")).render(
        <App
          hello={() => {
            console.log("hello");
          }}
        />
      );
    </script>
  </body>
</html>
